<?php

// $Id: vpage_sitemap_form_ctrl.class.php 1570 2009-01-13 12:44:02Z ogrebg $

require_once(TANGRA_MAIN_DIR.'form/gform_ctrl_with_obj.class.php');

require_once('vpage_sitemap_form.class.php');
require_once('vpage_sitemap_form_view.class.php');

require_once($WSC->get_site_inc_dir().'modules/tangra_cms/classes/vpage/tcms_vpage_dbc.class.php');


class VPage_Sitemap_Form_Ctrl extends GForm_Ctrl_With_Object {
	protected function create_form() {
		$form = new vpage_sitemap_Form();

//		$form->generate_html();
		return $form;
	}


	protected function create_form_view() {
		$ret = new VPage_Sitemap_Form_View($this->form);

		return $ret;
	}


	protected function on_good_submit() {
		$ret = true;

		return $ret;
	}


	protected function on_bad_submit() {

//		printbr('lajna');
	}


	protected function create_object() {
		$object = new TCMS_VPage_DBC();

		return $object;
	}


	protected function transfer_obj2form() {
		$object = $this->get_object();
		$form = $this->get_form();

		$form->set_field_value('in_sitemap', $object->get_in_sitemap());
		$form->set_field_value('sitemap_weight', (string)($object->get_sitemap_weight() / 10));
		$form->set_field_value('sitemap_change_freq', $object->get_sitemap_change_freq());
	}


	protected function transfer_form2obj() {
		$object = $this->get_object();
		$form = $this->get_form();

		$object->set_in_sitemap($form->get_field_value('in_sitemap'));
		$object->set_sitemap_weight($form->get_field_value('sitemap_weight') * 10);
		$object->set_sitemap_change_freq($form->get_field_value('sitemap_change_freq'));
	}
}